import http from '@/utils/http'

const BASE_URL = '/testing/project'

export interface ProjectResp {
  id: string
  projectAdmin: string
  name: string
  description: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ProjectDetailResp {
  id: string
  projectAdmin: string
  name: string
  description: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ProjectQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface ProjectPageQuery extends ProjectQuery, PageQuery {}

/** @desc 查询测试项目列表 */
export function listProject(query: ProjectPageQuery) {
  return http.get<PageRes<ProjectResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询测试项目详情 */
export function getProject(id: string) {
  return http.get<ProjectDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增测试项目 */
export function addProject(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改测试项目 */
export function updateProject(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除测试项目 */
export function deleteProject(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出测试项目 */
export function exportProject(query: ProjectQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
